﻿using System;

namespace Universities
{
    public class Student
    {
        private string name;
        private int fn;

        public Student(string name, int fn)
        {
            this.Name = name;
            this.Fn = fn;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("The name cannot be null.");
                }
                if (value == string.Empty)
                {
                    throw new ArgumentException("The name cannot be empty.");
                }
                name = value;
            }
        }

        public int Fn
        {
            get
            {
                return fn;
            }
            set
            {
                if (value < 10000 || value > 99999)
                {
                    throw new ArgumentOutOfRangeException("Faculty number is out of range.");
                }
                fn = value;
            }
        }

        public override bool Equals(object obj)
        {
            Student other = obj as Student;
            if (other == null)
            {
                return false;
            }
            return Fn.Equals(other.Fn);
        }

        public override int GetHashCode()
        {
            return Fn.GetHashCode();
        }
    }
}
